//<script type='text/javascript'>

	////////////////////////////////////////// EXTENTION: BAR: admin
var Admin = function ( vars ) {
	Object.extend(obj = new Element("div", {id:"admin", class:"ext admin"}), dashboard.ext.admin);
	
	//// BUILD admin UNIT
	
	obj.insert( obj.typeslgd = new Unit( "Types legenda" ).addClassName( "right" ));
	obj.insert( obj.settings = new Unit( "Admin settings." ));
	
	
	
	//obj.insert( unit = new Element( "ul", { class: "unit columns" + init.langs.length }));
	//unit.insert( li = new Element( "li" ).update( new Element( "h1", { class: "descr" }).update(  )));

	
	return obj.request();
}


dashboard.ext.admin	= {
	selected	: 0,
	addbutton	: function() {
		obj = new Element("div", { id:"dashboard.ext.adminbutton", class:"ext_button admin", name:"ext:admin" }).observe('click', dashboard.showhide );
		obj.ext = Admin;
		return obj;
	},

	request		: function() {

		new Ajax.Request( 'control.call.php', { parameters:{ set:Object.toJSON({type:'init', action:"admin", transfer_type: "js" })}, evalJSON: 'force', onComplete: this.seed.bind( this )});
		return this;
	},
	
	seed	: function( dict ) {
	
		json = dict.responseJSON;
	
		$H( json.settings ).each( function( o ){
			this.settings.content.insert( this.line( o.value.key, o.value.value ));
		}, this );
		
		$H( json.typeslgd ).each( function( o ){
			this.typeslgd.content.insert( this.line( o.key, o.value.descr  || "..." ));
		}, this );

		
		this.settings.content.insert( new Element( "li" ).update( new Element( "span", { class:"plus" }).observe( "click", this.add.bind( this ) )));
		this.typeslgd.content.insert( new Element( "li" ).update( new Element( "span", { class:"plus" }).observe( "click", this.add.bind( this ) )));

		this.settings.enableScroll( 320 );
		this.typeslgd.enableScroll( 320 );
		
	},
	
	line	: function( key, value ) {
		
		li = new Element("li").update( descr = new Element( "input", { type:"text", class: "descr", value: key }).observe( "change", this.update ));
		descr.vars = { key: id, is_key: true };
		
		li.insert( el = new Element( "input", { type: "text", value: value }).observe( "change", this.update ));
		el.vars = { key: key };

		return li;
	},
	
	add		: function( e ) {
		console.log(  )
		e.currentTarget.insert( {before: this.line( "...", {} )});
		
		this.settings.calcHandle();
	},
	
	update	: function( e ) {

		//this.vars.value = this.value;
		//xhttp.send( 'control.call.php', { transfer_type:'push', type:"text", action:"dictionary_update", vars:this.vars });
		
		//if( this.vars.is_key )
			//this.up().select( "input" ).each( function( el ){ el.vars.key = this.value; }, this );
	}
}
